package com.mokee.android.Setting;

import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Process;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.mokee.android.Login.LoginActivity;
import com.mokee.android.SharedPreference.MyValuesString;
import com.mokee.android.ShipPass.MainActivity;
import com.mokee.android.ShipPass.R;

public class SettingActivity extends Activity implements OnClickListener {
	private static final String tag = "SettingActivity";
	private TextView tv_AboutSoftware, tv_ExitSoftware;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_setting);

		initView();
		initEvent();
	}

	private void initView() {
		tv_AboutSoftware = (TextView) findViewById(R.id.tv_AboutSoftware);
		tv_ExitSoftware = (TextView) findViewById(R.id.tv_ExitSoftware);
	}

	private void initEvent() {
		tv_AboutSoftware.setOnClickListener(this);
		tv_ExitSoftware.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.tv_ExitSoftware:
			// 第一种
			// ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
			// activityManager.killBackgroundProcesses("com.mokee.android.ShipPass");
			// 第二种
			// activityManager.restartPackage("com.mokee.android.ShipPass");
			// 第三种
			// Process.killProcess(Process.myPid());
			
			// 退出MainActivity
			MainActivity.getInstance().exit();
			// 密码置空
			MyValuesString.setLoginPassward("");
			// 进入登陆界面
			Intent exitIntent = new Intent(SettingActivity.this, LoginActivity.class);
			startActivity(exitIntent);
			// 销毁该Activity
			finish();
			onDestroy();
			
			break;
			
		case R.id.tv_AboutSoftware:
			
			break;

		default:
			break;
		}
	}
}
